<?php
header("Content-Type:text/html;   charset=utf-8"); ?>
<script type="text/javascript">

    $(function(){
        loadColumn();
        $("#btnQueryColumn").bind("click",loadColumn);
        $("#hrefDelColumn").bind("click",delSelectColumn);
        $("#hrefAddColumn").bind("click",addColumn);
    });
    function delSelectMultiColumn(ids){
        var params={ids:ids};
        var url="admin.php/article/deleteColumn";
        $.ajax({
            type:"post",
            url:url,
            dataType:"json",
            data:params,
            success:function(data){

                if(data.ReturnCode=="1"){
                    loadColumn();
                    alert('删除成功');
                }else{
                    alert('删除失败');
                }
            }
        });
    }
    function delSelectColumn(){
        var selIds=getSelectIdsColumn();
        if(selIds==""){
            alert('请选择要删除的项');
            return;
        }
        if(confirm('删除后不可恢复，确认要删除吗？')==false)
            return;
        delSelectMultiColumn(selIds);
    }
    function delColumn(id){
        if(confirm('确定要删除吗？')==false)
            return;
        delSelectMultiColumn(id);
    }

    function getSelectIdsColumn(){
        var sel = "";
        $("#tableColumn td :checkbox:checked").each(function(){
            sel+=$(this).val()+",";
        });
        return sel;
    }

    function loadColumn(){
        $("#chkSelectAllColumn").attr("checked",false);
        var url="admin.php/article/loadColumn";
        $.ajax({
            type:"post",
            url:url,
            dataType:"html",
            success:function(data){
                $("#tableColumn").html(data);
                bindSelect("chkSelectAllColumn","tableColumn");
            }
        });
    }

    function modifyColumn(id){
        $("#hrefEditColumn").attr("href","admin.php/article/add_column?id="+id);
        $("#hrefEditColumn").trigger("click");
    }

    function addColumn(){
        $("#hrefEditColumn").attr("href","admin.php/article/add_column");
        $("#hrefEditColumn").trigger("click");
    }
</script>
<div class="pageContent">
    <div class="panelBar">
        <ul class="toolBar">
            <li style="display: none"><a id="hrefEditColumn" class="edit" href="" lookupgroup="orgLookup"><span>修改</span></a></li>
            <li><a id="hrefAddColumn" class="add" href="javascript:void(0)"><span>添加分类</span></a></li>
            <li><a id="hrefDelColumn" class="delete" href="javascript:void(0)"><span>删除</span></a></li>
        </ul>
    </div>
    <table class="table" width="100%" layoutH="138">
        <thead>
        <tr>
            <th style='width: 30px; text-align: center;'><input type='checkbox' id='chkSelectAllColumn' /></th>
            <th style='width: 40px'>编号</th>
            <th style='width: 900px;'>分类名称</th>
            <th style='width: 120px'>操作</th>
        </tr>
        </thead>
        <tbody id="tableColumn">

        </tbody>
    </table>
</div>